<?php

namespace App\Http\Controllers\Agency;
use App\Http\Controllers\Controller;
use App\Services\CrowdService;
use Illuminate\Http\Request;
use hg\apidoc\annotation as Apidoc;
/**
 * 搭子管理
 * @Apidoc\Group("market")
 */
class CrowdController extends Controller
{
    /**
     * @Apidoc\Title ("搭子管理-搭子列表")
     * @Apidoc\Url("/agency/getCrowdList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=true,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=true,desc="每页条数")
     * @Apidoc\Param("name",type="int",require=false,desc="搭子名称")
     * @Apidoc\Param("isopen",type="string",require=false,desc="启用状态Y启用；N禁用")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("name",type="string",desc="搭子名称")
     * @Apidoc\Returned("cover",type="string",desc="封面图")
     * @Apidoc\Returned("type",type="string",desc="付费类型0均不免费1男免费2女免费")
     * @Apidoc\Returned("price",type="string",desc="费用")
     * @Apidoc\Returned("desc",type="string",desc="描述")
     * @Apidoc\Returned("order",type="int",desc="排序")
     * @Apidoc\Returned("backimg",type="int",desc="背景图")
     * @Apidoc\Returned("nums",type="int",desc="群人数")
     * @Apidoc\Returned("isopen",type="string",desc="是否启用Y启用；N禁用")
     * @Apidoc\Returned("gender",type="int",desc="条件-性别")
     * @Apidoc\Returned("isreal",type="string",desc="条件-是否实名0不限1已实名认证")
     * @Apidoc\Returned("province",type="string",desc="条件-现居地省code")
     * @Apidoc\Returned("province_name",type="string",desc="条件-现居地省名称")
     * @Apidoc\Returned("city",type="string",desc="条件-现居地市code")
     * @Apidoc\Returned("city_name",type="string",desc="条件-现居地市名称")
     * @Apidoc\Returned("area",type="string",desc="条件-现居地区code")
     * @Apidoc\Returned("area_name",type="string",desc="条件-现居地区名称")
     * @Apidoc\Returned("reside_province",type="string",desc="条件-户籍地省code")
     * @Apidoc\Returned("reside_province_name",type="string",desc="条件-户籍地省名称")
     * @Apidoc\Returned("reside_city",type="string",desc="条件-户籍地市code")
     * @Apidoc\Returned("reside_city_name",type="string",desc="条件-户籍地市名称")
     * @Apidoc\Returned("reside_area",type="string",desc="条件-户籍地区code")
     * @Apidoc\Returned("reside_area_name",type="string",desc="条件-户籍地区名称")
     * @Apidoc\Returned("minage",type="int",desc="条件-最小年龄")
     * @Apidoc\Returned("maxage",type="int",desc="条件-最大年龄")
     * @Apidoc\Returned("marry",type="array",desc="条件-婚况")
     * @Apidoc\Returned("education",type="array",desc="条件-学历")
     * @Apidoc\Returned("house",type="array",desc="条件-房产")
     * @Apidoc\Returned("car",type="array",desc="条件-车子")
     * @Apidoc\Returned("created_at",type="object",desc="发布时间")
     */
    public function getCrowdList(Request $request ,CrowdService $crowdService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $crowdService->getCrowdList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("搭子管理-保存搭子")
     * @Apidoc\Url("/agency/crowdUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=false,desc="列表id")
     * @Apidoc\Param("name",type="string",require=true,desc="搭子名称")
     * @Apidoc\Param("cover",type="string",require=true,desc="封面图")
     * @Apidoc\Param("type",type="int",require=true,desc="0都不免费；1男免费；2女免费")
     * @Apidoc\Param("price",type="int",require=true,desc="费用")
     * @Apidoc\Param("desc",type="string",require=true,desc="描述")
     * @Apidoc\Param("order",type="int",require=true,desc="排序")
     * @Apidoc\Param("backimg",type="string",require=true,desc="背景图片")
     * @Apidoc\Param("isopen",type="string",require=true,desc="启用状态Y启用N禁用")
     * @Apidoc\Param("gender",type="int",require=false,desc="1男2女")
     * @Apidoc\Param("isreal",type="int",require=false,desc="0不限2已实名")
     * @Apidoc\Param("province",type="int",require=false,desc="")
     * @Apidoc\Param("province_name",type="int",require=false,desc="")
     * @Apidoc\Param("city",type="int",require=false,desc="")
     * @Apidoc\Param("city_name",type="int",require=false,desc="")
     * @Apidoc\Param("area",type="int",require=false,desc="")
     * @Apidoc\Param("area_name",type="int",require=false,desc="")
     * @Apidoc\Param("reside_province",type="int",require=false,desc="")
     * @Apidoc\Param("reside_province_name",type="int",require=false,desc="")
     * @Apidoc\Param("reside_city",type="int",require=false,desc="")
     * @Apidoc\Param("reside_city_name",type="int",require=false,desc="")
     * @Apidoc\Param("reside_area",type="int",require=false,desc="")
     * @Apidoc\Param("reside_area_name",type="int",require=false,desc="")
     * @Apidoc\Param("minage",type="int",require=false,desc="年龄区间")
     * @Apidoc\Param("maxage",type="int",require=false,desc="年龄区间")
     * @Apidoc\Param("marry",type="object",require=false,desc="婚况")
     * @Apidoc\Param("education",type="object",require=false,desc="学历")
     * @Apidoc\Param("house",type="object",require=false,desc="房产")
     * @Apidoc\Param("car",type="object",require=false,desc="车子")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function crowdUpdate(Request $request ,CrowdService $crowdService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $crowdService->crowdUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("搭子管理-删除搭子")
     * @Apidoc\Url("/agency/crowdDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=false,desc="列表id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function crowdDel(Request $request ,CrowdService $crowdService)
    {
        $params = $request->input();
        $result = $crowdService->crowdDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("搭子管理-保存启用状态")
     * @Apidoc\Url("/agency/crowdIsopenUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="列表id")
     * @Apidoc\Param("isopen",type="string",require=true,desc="Y启用N禁用")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function crowdIsopenUpdate(Request $request ,CrowdService $crowdService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $crowdService->crowdIsopenUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("搭子管理-报名列表")
     * @Apidoc\Url("/agency/getCrowdApplyList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",desc="页数")
     * @Apidoc\Param("pageSize",type="int",desc="每页条数")
     * @Apidoc\Param("username",type="int",desc="用户昵称")
     * @Apidoc\Param("mobile",type="int",desc="用户手机号")
     * @Apidoc\Param("type",type="int",desc="1付费；2免费")
     * @Apidoc\Param("status",type="string",desc="状态wait待审核；pass通过；refuse未通过")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("crowdName",type="string",desc="搭子名称")
     * @Apidoc\Returned("mid",type="string",desc="用户id")
     * @Apidoc\Returned("username",type="string",desc="用户昵称")
     * @Apidoc\Returned("mobile",type="string",desc="用户手机号")
     * @Apidoc\Returned("amount",type="string",desc="费用  0免费；不是0显示具体金额")
     * @Apidoc\Returned("status",type="int",desc="状态wait待审核；pass通过；refuse未通过；")
     * @Apidoc\Returned("created_at",type="object",desc="发布时间")
     */
    public function getCrowdApplyList(Request $request ,CrowdService $crowdService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $crowdService->getCrowdApplyList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("搭子管理-更新报名状态")
     * @Apidoc\Url("/agency/crowdApplyStatusUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("ids",type="int",require=true,desc="列表id  1,2,3,4....")
     * @Apidoc\Param("status",type="string",require=true,desc="wait待审核pass通过refuse拒绝")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function crowdApplyStatusUpdate(Request $request ,CrowdService $crowdService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $crowdService->crowdApplyStatusUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }
}
